package day240519_report.e5;

import java.util.Comparator;

public class ComplexComparator implements Comparator<Staff> {

    @Override
    public int compare(Staff o1, Staff o2) {
        int nameCompare = o1.getName().compareTo(o2.getName());
        int ageCompare = o1.getAge() - o2.getAge();
        return nameCompare == 0 ? ageCompare : nameCompare;// 名字主排序，年龄次排序
    }

}
